<template>
  <div id="register">
    <h3>用户注册</h3>
    <van-form @submit="onSubmit">
      <van-field
        v-model="temp.userName"
        name="用户名"
        label="用户名"
        placeholder="用户名"
        :rules="[{ required: true, message: '请填写用户名' }]"
      />
      <van-field
        v-model="temp.password"
        name="密码"
        label="密码"
        placeholder="密码"
        type="password"
        :rules="[{ required: true, message: '请填写密码' }]"
      />
      <van-field
        v-model="temp.nick"
        name="昵称"
        label="昵称"
        placeholder="昵称"
        :rules="[{ required: true, message: '请填写昵称' }]"
      />
      <van-field
        v-model="temp.mobile"
        name="手机号"
        label="手机号"
        placeholder="手机号"
        :rules="[{ required: true, message: '请填写手机号' }]"
      />
      <van-field
        v-model="temp.email"
        name="邮箱"
        label="邮箱"
        placeholder="邮箱"
        :rules="[{ required: true, message: '请填写邮箱' }]"
      />
      <div style="margin: 16px">
        <van-button round block type="info" native-type="submit"
          >提交</van-button
        >
      </div>
    </van-form>
  </div>
</template>

<script>
import { save } from "@/api/user";
export default {
  data() {
    return {
      temp: {
        userName: "longbrother",
        password: "lzp666",
        nick: "隔壁老龙",
        mobile: "15115282455",
        email: "longzipeng@foxmail.com",
      },
    };
  },
  methods: {
    onSubmit(values) {
      save(this.temp).then((Response) => {
        if (Response.code === "200") {
          this.$notify({
            message: "注册成功！！",
            type: "success",
          });
          this.$router.push("/login");
        }
      });
    },
  },
};
</script>

<style>
#register h3 {
    color:orange;
    font-size: 40px;
    text-align: center;
  }
</style>